Skip to content

fix(agent-context): apply default markers when config markers are blank (bash)#3736

Open
matecardoso wants to merge 1 commit into
github:mainfrom
matecardoso:fix/agent-context-bash-blank-markers
Open

fix(agent-context): apply default markers when config markers are blank (bash)#3736
matecardoso wants to merge 1 commit into
github:mainfrom
matecardoso:fix/agent-context-bash-blank-markers

Conversation

@matecardoso

Copy link
Copy Markdown

Description

Closes #3735.

When the extension config omits context_markers (or sets them blank) to rely on the built-in defaults, the Bash port aborted with malformed config parser output and never updated the context file, while the Python (... or DEFAULT_*) and PowerShell (default-initialized) ports handled it correctly.

The config parser prints three lines (context_files JSON, marker_start, marker_end), captured via _raw_opts="$(...)". Command substitution strips trailing newlines, so blank marker lines collapse the output to fewer than three, tripping the (( ${#_opts_lines[@]} < 3 )) guard and making the DEFAULT_START/DEFAULT_END substitution below unreachable — the exact case it was written for.

Fix: require only the mandatory context_files line, and default the marker lines to empty (${_opts_lines[1]:-} / ${_opts_lines[2]:-}) so the existing default-marker substitution fills them in. Single source of truth for the defaults stays in the Bash script.

Testing

  • Ran existing tests with pytest tests/extensions/213 passed, 63 skipped (PowerShell parity skipped: no pwsh locally).
  • Added test_python_blank_markers_use_defaults_matching_bash to the parity suite. Verified it fails on the old guard (Bash exits without updating while Python writes the section → parity mismatch) and passes with the fix.
  • Tested with a sample project (if applicable)

AI Disclosure

  • I did use AI assistance (describe below)

The fix and the regression test were written by Claude (Anthropic) under my direction, and I reviewed them. The bug surfaced while enabling this extension in a downstream project; an automated code review flagged the cross-platform divergence, which I traced to the command-substitution newline-stripping interacting with the 3-line guard.

…nk (bash)

When the extension config omits context_markers (or sets them blank),
relying on the built-in defaults, the Bash port aborted with "malformed
config parser output" and never updated the context file, while the
Python (`or DEFAULT_*`) and PowerShell (default-initialized) ports handled
it correctly.

The config parser prints three lines (context_files JSON, marker_start,
marker_end), captured via `_raw_opts="$(...)"`. Command substitution strips
trailing newlines, so blank marker lines collapse the output to fewer than
three, tripping the `(( ${#_opts_lines[@]} < 3 ))` guard and making the
DEFAULT_START/END substitution unreachable — the exact case it was written
for.

Require only the context_files line and default the marker lines to empty
(`${_opts_lines[1]:-}` / `${_opts_lines[2]:-}`) so the existing
DEFAULT_START/END fallback fills them in. Add a parity regression test with
blank markers (it fails on the old guard and passes with the fix).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 25, 2026 00:58
@matecardoso
matecardoso requested a review from mnriem as a code owner July 25, 2026 00:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Bash agent-context updates when markers are omitted or blank, restoring parity with Python and PowerShell.

Changes:

  • Accepts missing marker lines and applies built-in defaults.
  • Adds regression coverage for blank markers and cross-port parity.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
extensions/agent-context/scripts/bash/update-agent-context.sh Handles stripped blank marker lines safely.
tests/extensions/test_update_agent_context_python_parity.py Tests default-marker behavior and Bash/Python parity.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: agent-context Bash port aborts as "malformed" when config markers are blank, instead of using defaults

2 participants